package teamproject.graphEditor.graphGenerators;

import teamproject.graphEditor.Controller;
import teamproject.graphEditor.Node;
import teamproject.graphEditor.PDEEdge;
import edu.uci.ics.jung.graph.DirectedGraph;
import edu.uci.ics.jung.graph.DirectedSparseGraph;

/**
 * Generates a diamond network represented by a directed graph
 */
public class DiamondNetworkGenerator implements GraphGenerator {

	private Controller control;
	private DirectedGraph<Node, PDEEdge> g;

	public DiamondNetworkGenerator(Controller control) {
		this.control = control;
	}

	@Override
	public DirectedGraph<Node, PDEEdge> generateGraph() {
		// control.getGraphEditor().clearGraph();
		g = new DirectedSparseGraph<Node, PDEEdge>();
		g = (DirectedGraph<Node, PDEEdge>) control.initNewGraph(g);

		Node n1, n2, n3, n4, n5, n6;

		g.addVertex(n1 = control.getNodeFactory().create());
		g.addVertex(n2 = control.getNodeFactory().create());
		g.addVertex(n3 = control.getNodeFactory().create());
		g.addVertex(n4 = control.getNodeFactory().create());
		g.addVertex(n5 = control.getNodeFactory().create());
		g.addVertex(n6 = control.getNodeFactory().create());

		g.addEdge(control.getEdgeFactory().create(), n1, n2);
		g.addEdge(control.getEdgeFactory().create(), n2, n3);
		g.addEdge(control.getEdgeFactory().create(), n2, n4);
		g.addEdge(control.getEdgeFactory().create(), n3, n4);
		g.addEdge(control.getEdgeFactory().create(), n3, n5);
		g.addEdge(control.getEdgeFactory().create(), n4, n5);
		g.addEdge(control.getEdgeFactory().create(), n5, n6);

		return g;
	}

}
